package design.pattern.facade;

/**
 * 外观类，客户主要和本类进行交互
 * @author AtoVio, Winter Yuan
 */
public class SmartAppliancesFacade {

    // 聚合对象
    private Light light;
    private TV tv;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }

    public void control(String msg) {
        if (msg.contains("打开")) {
            on();
        } else if (msg.contains("关闭")) {
            off();
        }else {
            System.out.println("你说啥?");
        }
    }

    public void on() {
        light.on();
        tv.on();
        airCondition.on();
    }

    public void off() {
        light.off();
        tv.off();
        airCondition.off();
    }
}
